<?php

namespace App\depository;

use App\Enum\TeamsEnum;
use App\Models\TeamDictModel;

class TeamDictDep
{
    public $model;

    public function __construct()
    {
        $this->model = new TeamDictModel();
    }

    public function add($data)
    {
        $res = $this->model->insert($data);
        return $res;
    }

    public function addGetId($data)
    {
        $res = $this->model->insertGetId($data);
        return $res;
    }

    public function upd($id, $data)
    {
        $res = $this->model->where('id', $id)->update($data);
        return $res;
    }

    public function del($id)
    {
        $res = $this->model->where('id', $id)->delete();
        return $res;
    }

    public function list()
    {
        $res = $this->model->get();
        return $res;
    }

    public function getByTeamId($teamId)
    {
        $res = $this->model->where('team_id',$teamId)->get();
        return $res;
    }

    public function delByTeamId($teamId){
        $res = $this->model->where('team_id', $teamId)->delete();
        return $res;
    }

    public function get_list_by_gh_id($gh_id)
    {
        return $this->model->select(['team_id', 'label', 'value'])->where('team_id', $gh_id)->get()->toArray();
    }
}
